package com.qf.zyh.services.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.zyh.dao.EmpMapper;
import com.qf.zyh.entity.Emp;
import com.qf.zyh.services.EmpSer;
import com.qf.zyh.util.MyBatisUtils;

import java.util.List;

public class EmpSerImpl implements EmpSer {

    @Override
    public List<Emp> getall() {
        EmpMapper mapper = MyBatisUtils.getMapper(EmpMapper.class);
        List<Emp> all = mapper.getAll();
        MyBatisUtils.commit();
        MyBatisUtils.close();
        return all;
    }

    @Override
    public PageInfo<Emp> getEmpPage(int pageIndex) {
        EmpMapper mapper = MyBatisUtils.getMapper(EmpMapper.class);
        PageHelper.startPage(pageIndex,2);
        List<Emp> all = mapper.getAll();
        PageInfo<Emp> empp = new PageInfo<>(all);
        return empp;
    }
}
